-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DOC: update the pandas.DataFrame.pct_change docstring #20310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC: update the pandas.DataFrame.pct_change docstring #20310
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR! Added a few comments
pandas/core/generic.py
Outdated
freq : DateOffset, timedelta, or offset alias string, optional | ||
Increment to use from time series API (e.g. 'M' or BDay()) | ||
Increment to use from time series API (e.g. 'M' or BDay()). | ||
kwargs : mapping, optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kwargs : mapping, optional
-> **kwargs
pandas/core/generic.py
Outdated
Increment to use from time series API (e.g. 'M' or BDay()) | ||
Increment to use from time series API (e.g. 'M' or BDay()). | ||
kwargs : mapping, optional | ||
A dictionary of keyword arguments passed into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a dictionary, but just additional keywords, so you cna make this ""Additional keyword arguments are passed .."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But on second thought, are there actually additional keywords for shift?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what it's mapped to
Lines 7561 to 7562 in 7169830
rs = (data.div(data.shift(periods=periods, freq=freq, axis=axis, | |
**kwargs)) - 1) |
pandas/core/generic.py
Outdated
|
||
Returns | ||
------- | ||
chg : %(klass)s | ||
chg : Series or DataFrame, same type as the input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'input' -> 'calling object'
pandas/core/generic.py
Outdated
See Also | ||
-------- | ||
pandas.DataFrame.diff : see the difference of two columns | ||
pandas.Series.diff : see the difference of two columns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this above the "Examples" section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can also remove the pandas.
prefix I think.
pandas/core/generic.py
Outdated
freq : DateOffset, timedelta, or offset alias string, optional | ||
Increment to use from time series API (e.g. 'M' or BDay()) | ||
Increment to use from time series API (e.g. 'M' or BDay()). | ||
**kwargs : mapping, optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove the type here. Just **kwargs
.
pandas/core/generic.py
Outdated
Increment to use from time series API (e.g. 'M' or BDay()). | ||
**kwargs : mapping, optional | ||
Additional keyword arguments are passed into | ||
``DataFrame.shift``/``Series.shift``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single backticks. "or" instead of /
pandas/core/generic.py
Outdated
|
||
Returns | ||
------- | ||
chg : %(klass)s | ||
chg : Series or DataFrame, same type as the calling object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change : Series or DataFrame
The same type as the calling object.
pandas/core/generic.py
Outdated
|
||
Notes | ||
----- | ||
|
||
By default, the percentage change is calculated along the stat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think most users will understand stat
access. Best to remove this and only focus on Series / DataFrame.
pandas/core/generic.py
Outdated
By default, the percentage change is calculated along the stat | ||
axis: 0, or ``Index``, for ``DataFrame`` and 1, or ``minor`` for | ||
``Panel``. You can change this with the ``axis`` keyword argument. | ||
|
||
Percentage change in French franc, Deutsche Mark, and Italian lira from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move under the "Examples" header.
1980-01-01 NaN NaN NaN | ||
1980-02-01 0.013810 0.013684 0.006549 | ||
1980-03-01 0.053365 0.059318 0.061876 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show an example with axis='columns'
. Can use the same DataFrame, even though it's a silly example for axis=1.
pandas/core/generic.py
Outdated
See Also | ||
-------- | ||
pandas.DataFrame.diff : see the difference of two columns | ||
pandas.Series.diff : see the difference of two columns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can also remove the pandas.
prefix I think.
Codecov Report
@@ Coverage Diff @@
## master #20310 +/- ##
==========================================
+ Coverage 91.7% 91.72% +0.02%
==========================================
Files 150 150
Lines 49165 49165
==========================================
+ Hits 45087 45099 +12
+ Misses 4078 4066 -12
Continue to review full report at Codecov.
|
Note that it's immedate, but configurable. no type on kwargs. Example with periods. Moved See Also.
Made some touchups. Thanks @myles! |
@TomAugspurger small comment on when merging: can you remove all the different commit messages (in case of those DOC PRs it's mostly useless to keep them). It's maybe not that important and only my nitpicky self, but it's only a "click in box, ctrl-A, del" combo away :-) |
👍 |
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks: